package com.jdd.modules.people.util;

import cn.hutool.log.Log;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.DeleteMapping;

/**
 * @Author: LS
 * @Date: 2022 - 09 - 28 - 19:49
 * @Description: 用来生成编号
 * @version: 1.0
 */
@Slf4j
public class SetOrgCodeUtil {
    /**
     * @param parentCode 父亲code
     * @param lastOrgCode  最大code
     * @param sign  标识 A D 等
     * @return
     */
    public static String generateOrgCode(String parentCode,String lastOrgCode,String sign){
        String orgCode="";
        if(StringUtils.isEmpty(lastOrgCode)) {
            orgCode=parentCode+sign+1;
            return orgCode;
        }else{
            int code = (Integer.parseInt(lastOrgCode.substring(lastOrgCode.lastIndexOf(sign)+1),lastOrgCode.length()) + 1);
            log.info("code:{}",code);
            orgCode =parentCode + sign +code;
        }
        return orgCode;
    }
}
